package cn.tedu.egmvc1.controller;

import cn.tedu.egmvc1.pojo.dto.InsertUserDTO;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class UserController {

    /*
     http://localhost:8080/v1/users/insert?username=&nickname=&password=
   */
    @RequestMapping(value = "v1/users/insert")
    @ResponseBody
    public String insert(String nickname, String password, String username) {
        return "添加用户成功"+nickname + "-" + password + "-" + username;
    }

    @RequestMapping(value = "/v1/users/userList")
    @ResponseBody
    public String userList(List<String> list) {
        return "查询用户列表成功" + list;
    }

    @RequestMapping(value = "/v1/users/delete")
    @ResponseBody
    public String delete(Integer id) {
        return "删除成功" + id;
    }

    @RequestMapping(value = "/v1/users/update")
    @ResponseBody
    public String update(InsertUserDTO insertUserDTO) {
        Integer id = insertUserDTO.getId();
        String username = insertUserDTO.getUsername();
        String nickname = insertUserDTO.getNickname();
        String password = insertUserDTO.getPassword();
        return "更新成功"+id + "-" + username + "-" + nickname + "-" + password;
    }
}
